import request from "../utils/request";

// 登录
export function login(data: { userName: string, password: string }) {
	//   return request({
	// 	method: 'post',
	//     url: '/user/login',
	//     data
	//   })
	return new Promise((resolve, reject) => {
		if (data.userName == 'zhaoxy') {
			let obj = {
				roles: ['admin'],
				token: '111111',
				userInfo: {
					nickName: '是editor呢',
					signature: '思密达 Vue3'
				}
			}
			resolve(obj)
		} else {
			let obj = {
				roles: ['editor'],
				token: '222222',
				userInfo: {
					nickName: '是editor呢',
					signature: '萨瓦迪卡 Vue3'
				}
			}
			resolve(obj)
		}
	})
}

// 获取用户信息
export function getUserInfo(token: string) {
	//   return request({
	// 	method: 'post',
	//     url: '/user/userinfo',
	//     data:data
	//   })
	return new Promise((resolve, reject) => {
		if (token == '111111') {
			let obj = {
				roles: ['admin'],
				nickName: '是editor呢',
				signature: '思密达 Vue3'
			}
			resolve(obj)
		} else {
			let obj = {
				roles: ['editor'],
				nickName: '是editor呢',
				signature: '萨瓦迪卡 Vue3'
			}
			resolve(obj)
		}
	})
}

// 用户退出
export function Logout() {
	return request({
		method: 'get',
		url: '/user/logout',
	})
}